#include <iostream>
using namespace std;
int main()
{
    int a[2][3] = {0};
    //

    int count;
    cin >> count;
    int *p = a[0];
    for (int i = 0; i < count; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            for (int k = 0; k < 3; k++)
            {
                cin >> a[j][k];
                /* code */
            }

            /* code */
        }
        for (int i = 2; i >= 0; i--)
        {
            for (int j = 0; j < 2; j++)
            {
                cout << *(p + i + j * 3) << " ";
                /* code */
            }
            cout << endl;
            /* code */
        }

        /* code */
    }

    return 0;
}
